// component/j-linkUs/j-linkUs.js
var app = getApp();
var WxParse = require('../../wxParse/wxParse.js');
Component({
	/**
	 * 组件的属性列表
	 */
	properties: {
		keyCatid: {
			type: Number,
			value: 0,
			observer: function (newVal, oldVal) {
				var that = this;
				wx.request({
					url: app.globalData.host + 'index.php/api/goods/goodsInfo?admin_id=' + app.globalData.admin_id + '&type=' + newVal + '&code=3',
					success: function (e) {
						// console.log(e)
						that.setData({
							items: e.data.result[0],
							phone: e.data.result[0].goods_remark.split(',')[0],
							lat: parseFloat(e.data.result[0].goods_remark.split(',')[1]),
							long: parseFloat(e.data.result[0].goods_remark.split(',')[2]),
							markers: [
								{
									id: 0,
									latitude: parseFloat(e.data.result[0].goods_remark.split(',')[1]),
									longitude: parseFloat(e.data.result[0].goods_remark.split(',')[2]),
									height: 50,
									callout: {
										content: e.data.result[0].goods_name,
										borderRadius: 10,
										bgColor: '#43BAF2',
										color: '#fff',
										padding: 10,
										display: 'ALWAYS'
									}
								}
							]
						})
						// console.log(e.data.result[0])
						var article = e.data.result[0].goods_content;
						WxParse.wxParse('article', 'html', article, that, 8);
					}
				})
			}
		},
		color:{
			type: String,
			value: '#2a2a2a',
		}
	},

	/**
	 * 组件的初始数据
	 */
	data: {
		
	},

	/**
	 * 组件的方法列表
	 */
	methods: {
		call:function(){
			wx.makePhoneCall({
				phoneNumber: this.data.phone,
			})
		},
		go: function () {
			var that = this
			wx.getLocation({
				type: 'gcj02', //返回可以用于wx.openLocation的经纬度
				success: function (res) {
					wx.openLocation({
						latitude: that.data.lat,
						longitude: that.data.long,
						scale: 14,
						name: that.data.items.goods_name
					})
				}
			});
		},
	}
})
